using System;
using System.Data;
using System.Web;
using System.Web.Configuration;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class ListBoxPage : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
         if(!IsPostBack)
         {
            LoadData();
           
         }
    }
    void LoadData()
    {
        string connectionString =
                WebConfigurationManager.ConnectionStrings[
                "RCVDB2000"].ConnectionString;

        ControlHelper cls = new
        ControlHelper(connectionString);
        cls.CommandText = 
        "select * from tblProvinces";
        cls.CommandType = CommandType.Text;
        cls.InitProperties();
        cls.FillDataTableToListBox(
        this.ListBox1, 
        "ProvinceName", "ProvinceID","");         
        cls.Finalize();   
    }
    protected void ListBox1_SelectedIndexChanged(object sender, EventArgs e)
    {
        ListBox listBox = (ListBox)sender;
        this.Literal1.Text = 
        listBox.SelectedValue + "-" + 
        listBox.SelectedItem.Text;
    }
     
}
